#include "specialization.h"

#include "database.h"

const QString Specialization::KEY_EFFORT = "effort";
const QString Specialization::KEY_TALENT = "talent";
const QString Specialization::KEY_RANK = "rank";
const QString Specialization::KEY_DISCIPLINE = "discipline";

Specialization::Specialization(const QMap<QString, QString> &values)
    : XMLItem(values)
{
    Q_ASSERT(values.contains(KEY_EFFORT));
    Q_ASSERT(values.contains(KEY_TALENT));
    Q_ASSERT(values.contains(KEY_RANK));
    Q_ASSERT(values.contains(KEY_DISCIPLINE));

    _effort = values[KEY_EFFORT];
    _talent = values[KEY_TALENT];
    _rank = values[KEY_RANK];
    _discipline = values[KEY_DISCIPLINE];

    Q_ASSERT(!Database::talents(_talent).isEmpty());
}

QString Specialization::keyValue(const QString &key) const
{
    if (key == KEY_EFFORT) return effort();
    if (key == KEY_TALENT) return talent();
    if (key == KEY_RANK) return rank();
    if (key == KEY_DISCIPLINE) return discipline();

    return XMLItem::keyValue(key);
}
